/*
 * SemanticNodeMethodStatement.cpp
 *
 *  Created on: 03.11.2009.
 *      Author: hrvoje
 */
#include "SemanticNodeMethodStatement.h"
#include "SemanticNodeMethodBody.h"
#include "main2.h"
#include "SemanticNodeExpression.h"
#include "SemanticNodeVariableName.h"

/*

<variable_definition>	~	<trace_part> <data_type> <field_names> ;
<trace_part>	~	trace <numeric_mod>
<trace_part>	~

<numeric_mod>	~	discrete
<numeric_mod>	~	continuous

 */

SemanticNodeVariableDefinition::SemanticNodeVariableDefinition(const SyntaxTreeNode *tracePart, const SyntaxTreeNode *varType, const SyntaxTreeNode *varName, SemanticNode *parent):SemanticNode(parent), ValueType(getNextUniqueID()){
	traceContinuous = false;
	traceDiscrete = false;
	if (tracePart != NULL)
	{
		if (tracePart->Production == Gr_TracePart__trace_NumericMod){
			if (tracePart->Nodes->GetData(1)->Production == Gr_NumericMod__discrete)
				traceDiscrete = true;
			else
				traceContinuous = true;
		}
	}
	// obrada imena varijable i dimenzionalnosti
	initExpression = NULL;
	LexicUnit lu = CompilerData->Units->GetLexicUnit(varName->Nodes->GetData(0)->Nodes->GetData(0)->LexUnitID);
	name = CompilerData->Units->GetLexicUnitString(&lu);

	// obrada tipa podatka
	setType(varType, varName->Nodes->GetData(0)->Nodes->GetData(1)->Nodes->GetCount());
}
SemanticNodeVariableDefinition::~SemanticNodeVariableDefinition(){
	delete initExpression;
	initExpression = NULL;
}

std::vector<SemanticNodeVariableDefinition *> SemanticNodeVariableDefinition::analyzeNodeVariableDefinition(const SyntaxTreeNode *syntaxNode, SemanticNode *parent) {
	std::vector<SemanticNodeVariableDefinition *> snvd;
	SyntaxTreeNode *tracePart;
	SyntaxTreeNode *varType;
	SyntaxTreeNode *varName;

	switch(syntaxNode->Production){
	case Gr_VariableDefinition__TracePart_DataType_FieldNames_spSemiCol:
		tracePart = syntaxNode->Nodes->GetData(0);
		varType = syntaxNode->Nodes->GetData(1);
		varName = syntaxNode->Nodes->GetData(2);
		break;
	case Gr_SimpleStatement__DataType_FieldNames:
		tracePart = NULL;
		varType = syntaxNode->Nodes->GetData(0);
		varName = syntaxNode->Nodes->GetData(1);
		break;
	default:;
	}
	while (true) {
		SemanticNodeVariableDefinition *newVariable = new SemanticNodeVariableDefinition(tracePart, varType, varName, parent);
		SyntaxTreeNode *equals = varName->Nodes->GetData(1);
		if (equals->Production == Gr_Equals__opAssign_Expression) {
			newVariable->setInitExpression(OurSemanticAnalyzer::analyzeNodeExpression(equals->Nodes->GetData(1), newVariable)); //new SemanticNodeExpression(equals->Nodes->GetData(1), parent));
		}
		snvd.push_back(newVariable);
		varName = varName->Nodes->GetData(2);
		if (varName->Production == Gr_FieldNamesAdd__epsilon) break;
 	varName = varName->Nodes->GetData(1);
	}
	return snvd;
}

void SemanticNodeVariableDefinition::setInitExpression(SemanticNodeExpression *nodeExpression) {
	initExpression = nodeExpression;
}

std::string SemanticNodeVariableDefinition::getName(void) {
	return name;
}

bool SemanticNodeVariableDefinition::isInitialized() {
	return initExpression != NULL;
}

std::string SemanticNodeVariableDefinition::toDebugString(int tab){
	std::ostringstream res;
	for (int i = 0; i < tab; i++) res << DEBUG_STRING_RAZMAK;
	if (traceContinuous) res << "trace continuous ";
	if (traceDiscrete) res << "trace discrete ";
	res << this->getTypeDebugString() << " " << name;
	for (unsigned int x = 0; x < dimensions.size(); ++x) res << "[]";
	res << std::endl;
	if (isInitialized())
		res << initExpression->toDebugString(tab + 1);
	else {
		for (int i = 0; i < tab + 1; i++) res << DEBUG_STRING_RAZMAK;
		res << "null" << std::endl;
	}
	return res.str();
}


/*
 *
<assignment>	~	<variable_value> = <expression> ;
<assignment_derivation>	~	derivation <variable_value> = <expression> ;

 */

SemanticNodeAssignment::SemanticNodeAssignment(const SyntaxTreeNode *syntaxNode, SemanticNode *parent):SemanticNode(parent){
	switch(syntaxNode->Production){
	case Gr_SimpleStatement__VariableValue_opAssign_Expression:
	case Gr_Assignment__VariableValue_opAssign_Expression_spSemiCol:
		variableValue = OurSemanticAnalyzer::analyzeNodeVariableName(syntaxNode->Nodes->GetData(0), this);
		expression = OurSemanticAnalyzer::analyzeNodeExpression(syntaxNode->Nodes->GetData(2), this);
		break;
	case Gr_AssignmentDerivation__derivation_VariableValue_opAssign_Expression_spSemiCol:
		variableValue = OurSemanticAnalyzer::analyzeNodeVariableName(syntaxNode->Nodes->GetData(1), this);
		expression = OurSemanticAnalyzer::analyzeNodeExpression(syntaxNode->Nodes->GetData(3), this);
		break;
	default:;
	}
}
SemanticNodeAssignment::~SemanticNodeAssignment(){
	delete variableValue;
	variableValue = NULL;
	delete expression;
	expression = NULL;
}
std::string SemanticNodeAssignment::toDebugString(int tab){
	std::ostringstream res;
	res << variableValue->toDebugString(tab);
	for (int i = 0; i < tab; i++) res << DEBUG_STRING_RAZMAK;
	res << "=" << endl;
	res << expression->toDebugString(tab);
	return res.str();
}

/*
<method_call>	~	NAME ( <arguments> ) ;
<method_call>	~	<variable_value> . NAME ( <arguments> ) ;
*/

SemanticNodeMethodCall::SemanticNodeMethodCall(const SyntaxTreeNode *methodCallNode, SemanticNode *parent) : SemanticNode(parent), ValueType(getNextUniqueID()) {
	instanceCall = false;
	variableValue = NULL;
	LexicUnit lu;
	switch (methodCallNode->Production){
	case Gr_MethodCall__NAME_spLPar_Arguments_spRPar_spSemiCol:
	case Gr_SimpleStatement__NAME_spLPar_Arguments_spRPar:
	case Gr_Value__NAME_spLPar_Arguments_spRPar:
		lu = CompilerData->Units->GetLexicUnit(methodCallNode->Nodes->GetData(0)->LexUnitID);
		name = CompilerData->Units->GetLexicUnitString(&lu);
		arguments = OurSemanticAnalyzer::analyzeNodeArgument(methodCallNode->Nodes->GetData(2), this);
		break;
	case Gr_SimpleStatement__VariableValue_spPer_NAME_spLPar_Arguments_spRPar:
	case Gr_MethodCall__VariableValue_spPer_NAME_spLPar_Arguments_spRPar_spSemiCol:
	case Gr_Value__VariableValue_spPer_NAME_spLPar_Arguments_spRPar:
		instanceCall = true;
		variableValue = OurSemanticAnalyzer::analyzeNodeVariableName(methodCallNode->Nodes->GetData(0), parent);
		lu = CompilerData->Units->GetLexicUnit(methodCallNode->Nodes->GetData(2)->LexUnitID);
		name = CompilerData->Units->GetLexicUnitString(&lu);
		arguments = OurSemanticAnalyzer::analyzeNodeArgument(methodCallNode->Nodes->GetData(4), this);
		break;
	case Gr_ConstrInherit__spColon_Name_spLPar_Arguments_spRPar:
		name = flattenNamePeriodAdd(*methodCallNode->Nodes->GetData(1));
		arguments = OurSemanticAnalyzer::analyzeNodeArgument(methodCallNode->Nodes->GetData(3), this);
		break;
	default:;
	}
}

std::string SemanticNodeMethodCall::toDebugString(int tab) {
	std::ostringstream res;
	if (variableValue != NULL) res << variableValue->toDebugString(tab+1);
	for (int i = 0; i < tab; i++) res << DEBUG_STRING_RAZMAK;
	res << "call " << name << std::endl;
	for (int i = 0; i < tab; i++) res << DEBUG_STRING_RAZMAK;
	res << "arguments: " << std::endl;
	for (std::vector<SemanticNodeExpression *>::iterator i = arguments.begin(); i != arguments.end(); ++i)
		res << (*i)->toDebugString(tab + 1);
	return res.str();
}

bool SemanticNodeMethodCall::isInstanceMethodCall(void) {
	return instanceCall;
}

/*
<if_statement> ~ if ( <expression> ) <block_statement> <else_part>

<block_statement> ~ { <method_body> }
<else_part> ~ else <block_statement>
<else_part> ~ ?
 */

SemanticNodeIfStatement::SemanticNodeIfStatement(const SyntaxTreeNode *syntaxNode, SemanticNode *parent):SemanticNode(parent){
	expression = OurSemanticAnalyzer::analyzeNodeExpression(syntaxNode->Nodes->GetData(2), this);
	ifPart = new SemanticNodeMethodBody(syntaxNode->Nodes->GetData(4)->Nodes->GetData(1), this);
	switch (syntaxNode->Nodes->GetData(5)->Production){
		case Gr_ElsePart__else_BlockStatement:
			elsePart = new SemanticNodeMethodBody(syntaxNode->Nodes->GetData(5)->Nodes->GetData(1)->Nodes->GetData(1), this);
			break;
		case Gr_ElsePart__epsilon:
			elsePart = NULL;
			break;
		default:;
	}


}
SemanticNodeIfStatement::~SemanticNodeIfStatement(){
	delete expression;
	expression = NULL;
	delete ifPart;
	ifPart = NULL;
	delete elsePart;
	elsePart = NULL;
}
std::string SemanticNodeIfStatement::toDebugString(int tab){
	std::ostringstream res;
	for (int i = 0; i < tab; i++) res << DEBUG_STRING_RAZMAK;
	res << "if statement" << std::endl;
	res << expression->toDebugString(tab+1);
	for (int i = 0; i < tab; i++) res << DEBUG_STRING_RAZMAK;
	res << "if part:" << endl;
	res << ifPart->toDebugString(tab+1);
	if (elsePart != NULL){
		for (int i = 0; i < tab; i++) res << DEBUG_STRING_RAZMAK;
		res << "else part:" << endl;
		res << elsePart->toDebugString(tab+1);
	}
	return res.str();
}

/*

<while_statement> ~ while ( <expression> ) <block_statement>
<dowhile_statement> ~ do <block_statement> while ( <expression> ) ;

<block_statement> ~ { <method_body> }
 */

SemanticNodeWhileStatement::SemanticNodeWhileStatement(const SyntaxTreeNode *syntaxNode, SemanticNode *parent):SemanticNode(parent){
	switch (syntaxNode->Production){
	case Gr_WhileStatement__while_spLPar_Expression_spRPar_BlockStatement:
		isDoWhile = false;
		expression = OurSemanticAnalyzer::analyzeNodeExpression(syntaxNode->Nodes->GetData(2), this);
		body = new SemanticNodeMethodBody(syntaxNode->Nodes->GetData(4)->Nodes->GetData(1),this);
		break;
	case Gr_DowhileStatement__do_BlockStatement_while_spLPar_Expression_spRPar_spSemiCol:
		isDoWhile = true;
		expression = OurSemanticAnalyzer::analyzeNodeExpression(syntaxNode->Nodes->GetData(4), this);
		body = new SemanticNodeMethodBody(syntaxNode->Nodes->GetData(1)->Nodes->GetData(1),this);
		break;
	default: ;
	}
}
SemanticNodeWhileStatement::~SemanticNodeWhileStatement(){
	delete expression;
	expression = NULL;
}
std::string SemanticNodeWhileStatement::toDebugString(int tab){
	std::ostringstream res;
	for (int i = 0; i < tab; i++) res << DEBUG_STRING_RAZMAK;
	if (isDoWhile) res << "do ";
	res << "while " << std::endl;
	res << expression->toDebugString(tab+1);
	for (int i = 0; i < tab; i++) res << DEBUG_STRING_RAZMAK;
	res << "while body" << std::endl;
	res << body->toDebugString(tab+1);
	return res.str();
}

/*
 *
<for_statement> ~ for ( <simple_statement> ; <expression> ; <simple_statement> ) <block_statement>

<simple_statement> ~ <data_type> <field_names>
<simple_statement> ~ <variable_value> = <expression>
<simple_statement> ~ NAME ( <arguments> )
<simple_statement> ~ <variable_value> . NAME ( <arguments> )

<block_statement> ~ { <method_body> }
 */

SemanticNodeForStatement::SemanticNodeForStatement(const SyntaxTreeNode *syntaxNode, SemanticNode *parent):SemanticNode(parent){
	startStatement = NULL;
	countStatement = NULL;
	switch (syntaxNode->Nodes->GetData(2)->Production){
		case Gr_SimpleStatement__DataType_FieldNames:
			startVariables = SemanticNodeVariableDefinition::analyzeNodeVariableDefinition(syntaxNode->Nodes->GetData(2), this);
			break;
		case Gr_SimpleStatement__VariableValue_opAssign_Expression:
			startStatement = new SemanticNodeAssignment(syntaxNode->Nodes->GetData(2), this);
			break;
		case Gr_SimpleStatement__NAME_spLPar_Arguments_spRPar:
		case Gr_SimpleStatement__VariableValue_spPer_NAME_spLPar_Arguments_spRPar:
			startStatement = new SemanticNodeMethodCall(syntaxNode->Nodes->GetData(2), this);
			break;
		default:;
	}

	expression = OurSemanticAnalyzer::analyzeNodeExpression(syntaxNode->Nodes->GetData(4), this);

	switch (syntaxNode->Nodes->GetData(6)->Production){
		case Gr_SimpleStatement__DataType_FieldNames:
			countVariables = SemanticNodeVariableDefinition::analyzeNodeVariableDefinition(syntaxNode->Nodes->GetData(6), this);
			break;
		case Gr_SimpleStatement__VariableValue_opAssign_Expression:
			countStatement = new SemanticNodeAssignment(syntaxNode->Nodes->GetData(6), this);
			break;
		case Gr_SimpleStatement__NAME_spLPar_Arguments_spRPar:
		case Gr_SimpleStatement__VariableValue_spPer_NAME_spLPar_Arguments_spRPar:
			countStatement = new SemanticNodeMethodCall(syntaxNode->Nodes->GetData(6), this);
			break;
		default:;
	}

	body = new SemanticNodeMethodBody(syntaxNode->Nodes->GetData(8)->Nodes->GetData(1), this);
}
SemanticNodeForStatement::~SemanticNodeForStatement(){
	delete startStatement;
	delete expression;
	delete countStatement;
	startStatement = NULL;
	expression = NULL;
	countStatement = NULL;
}
std::string SemanticNodeForStatement::toDebugString(int tab){
	std::ostringstream res;
	for (int i = 0; i < tab; i++) res << DEBUG_STRING_RAZMAK;
	res << "for " << std::endl;
	for (std::vector<SemanticNodeVariableDefinition *>::iterator i = startVariables.begin(); i != startVariables.end(); ++i)
		res << (*i)->toDebugString(tab + 1);
	if (startStatement != NULL)
		res << startStatement->toDebugString(tab+1);
	for (int i = 0; i < tab; i++) res << DEBUG_STRING_RAZMAK;
		res << ";" << std::endl;
	res << expression->toDebugString(tab+1);
	for (int i = 0; i < tab; i++) res << DEBUG_STRING_RAZMAK;
			res << ";" << std::endl;
	for (std::vector<SemanticNodeVariableDefinition *>::iterator i = countVariables.begin(); i != countVariables.end(); ++i)
			res << (*i)->toDebugString(tab + 1);
	if (countStatement != NULL)
		res << countStatement->toDebugString(tab+1);
	for (int i = 0; i < tab; i++) res << DEBUG_STRING_RAZMAK;
			res << "for body:" << std::endl;
	res << body->toDebugString(tab+1);
	return res.str();
}

/*
<switch_case_statement> ~ switch ( <expression> ) { <switch_case_cases> <switch_case_default> }

<switch_case_cases> ~ <switch_case_case> <switch_case_cases>
<switch_case_cases> ~ ?

<switch_case_case> ~ case <expression> : <block_statement>

<switch_case_default> ~ default : <block_statement>
<switch_case_default> ~ ?

<block_statement> ~ { <method_body> }
*/

SemanticNodeSwitchCaseStatement::SemanticNodeSwitchCaseStatement(const SyntaxTreeNode *syntaxNode, SemanticNode *parent):SemanticNode(parent){
	expression = OurSemanticAnalyzer::analyzeNodeExpression(syntaxNode->Nodes->GetData(2), this);
	for (int i = 0; i < syntaxNode->Nodes->GetData(5)->Nodes->GetCount(); i++){
		SyntaxTreeNode *switchCaseCase = syntaxNode->Nodes->GetData(5)->Nodes->GetData(i);
		caseExpressions.push_back(OurSemanticAnalyzer::analyzeNodeExpression(switchCaseCase->Nodes->GetData(1), this));
		caseBodies.push_back(new SemanticNodeMethodBody(switchCaseCase->Nodes->GetData(3)->Nodes->GetData(1), this));
	}
	switch (syntaxNode->Nodes->GetData(6)->Production){
		case Gr_SwitchCaseDefault__default_spColon_BlockStatement:
			defaultBody = new SemanticNodeMethodBody(syntaxNode->Nodes->GetData(6)->Nodes->GetData(2)->Nodes->GetData(1), this);
			break;
		case Gr_SwitchCaseDefault__epsilon:
			defaultBody = NULL;
			break;
		default: ;
	}

}
SemanticNodeSwitchCaseStatement::~SemanticNodeSwitchCaseStatement(){
	delete expression;
	expression = NULL;
	delete defaultBody;
	defaultBody = NULL;
}
std::string SemanticNodeSwitchCaseStatement::toDebugString(int tab){
	std::ostringstream res;
	for (int i = 0; i < tab; i++) res << DEBUG_STRING_RAZMAK;
	res << "switch " << std::endl;
	res << expression->toDebugString(tab+1);
	for (unsigned int i = 0; i < caseExpressions.size(); ++i ){
		for (int j = 0; j < tab; j++) res << DEBUG_STRING_RAZMAK;
			res << "case " << std::endl;
		res << caseExpressions[i]->toDebugString(tab + 1);
		for (int j = 0; j < tab; j++) res << DEBUG_STRING_RAZMAK;
			res << ":" << std::endl;
		res << caseBodies[i]->toDebugString(tab+1);
	}
	return res.str();
}


/*
 * <break_statement>	~	break ;
 */

SemanticNodeBreakStatement::SemanticNodeBreakStatement(const SyntaxTreeNode *syntaxNode, SemanticNode *parent):SemanticNode(parent){
}

SemanticNodeBreakStatement::~SemanticNodeBreakStatement(){
}

std::string SemanticNodeBreakStatement::toDebugString(int tab){
	std::ostringstream res;
	for (int i = 0; i < tab; i++) res << DEBUG_STRING_RAZMAK;
	res << "break" << endl;
	return res.str();
}

/*
 * <continue_statement>	~	continue ;
 */

SemanticNodeContinueStatement::SemanticNodeContinueStatement(const SyntaxTreeNode *syntaxNode, SemanticNode *parent):SemanticNode(parent){
}
SemanticNodeContinueStatement::~SemanticNodeContinueStatement(){

}
std::string SemanticNodeContinueStatement::toDebugString(int tab){
	std::ostringstream res;
	for (int i = 0; i < tab; i++) res << DEBUG_STRING_RAZMAK;
	res << "continue" << endl;
	return res.str();
}

/*
<method_statement> ~ <return_statement>

<return_statement> ~ return <expression> ;
<return_statement> ~ return ;

 */

SemanticNodeReturnStatement::SemanticNodeReturnStatement(const SyntaxTreeNode *syntaxNode, SemanticNode *parent):SemanticNode(parent){
	switch(syntaxNode->Production){
		case Gr_ReturnStatement__return_Expression_spSemiCol:
			expression = OurSemanticAnalyzer::analyzeNodeExpression(syntaxNode->Nodes->GetData(1), this);
			break;
		case Gr_ReturnStatement__return_spSemiCol:
			expression = NULL;
			break;
		default:;
	}
}
SemanticNodeReturnStatement::~SemanticNodeReturnStatement(){
	delete expression;
	expression = NULL;
}
std::string SemanticNodeReturnStatement::toDebugString(int tab){
	std::ostringstream res;
	for (int i = 0; i < tab; i++) res << DEBUG_STRING_RAZMAK;
	res << "return " << endl;
	if (expression != NULL) res << expression->toDebugString(tab+1);
	return res.str();
}


/*
 * <goto_statement>	~	goto NAME ;
 */

SemanticNodeGotoStatement::SemanticNodeGotoStatement(const SyntaxTreeNode *syntaxNode, SemanticNode *parent):SemanticNode(parent){
	LexicUnit lu = CompilerData->Units->GetLexicUnit(syntaxNode->Nodes->GetData(1)->LexUnitID);
	name = CompilerData->Units->GetLexicUnitString(&lu);
}
SemanticNodeGotoStatement::~SemanticNodeGotoStatement(){
}
std::string SemanticNodeGotoStatement::toDebugString(int tab){
	std::ostringstream res;
	for (int i = 0; i < tab; i++) res << DEBUG_STRING_RAZMAK;
	res << "goto " << name << endl;
	return res.str();
}

/*

<method_statement>	~	<start_statement>

<start_statement>	~	start <name> ( <arguments> ) with <start_assignments> ;
<start_statement>	~	start <name> ( <arguments> ) ;
<start_assignments>	~	<start_assignment> <start_assignment_add>
<start_assignment_add>	~	<start_assignment_comma_add> <start_assignment_add>
<start_assignment_add>	~
<start_assignment_comma_add>	~	, <start_assignment>
<start_assignment>	~	NAME = <expression>

<name>	 ~ 	NAME <name_add>
<name_add>	 ~	<name_period_add> <name_add>
<name_add>	 ~
<name_period_add> ~	. NAME

*/

SemanticNodeStartStatement::SemanticNodeStartStatement(const SyntaxTreeNode *syntaxNode, SemanticNode *parent):SemanticNode(parent){
	name = flattenNamePeriodAdd(*syntaxNode->Nodes->GetData(1));
	arguments = OurSemanticAnalyzer::analyzeNodeArgument(syntaxNode->Nodes->GetData(3), this);
	SyntaxTreeNode *startAssignmentAdd;
	switch(syntaxNode->Production){
	case Gr_StartStatement__start_Name_spLPar_Arguments_spRPar_with_StartAssignments_spSemiCol:
		analyzeStartAssignment(syntaxNode->Nodes->GetData(6)->Nodes->GetData(0));
		startAssignmentAdd = syntaxNode->Nodes->GetData(6)->Nodes->GetData(1);
		for (int i = 0; i < startAssignmentAdd->Nodes->GetCount(); i++){
			analyzeStartAssignment(startAssignmentAdd->Nodes->GetData(i)->Nodes->GetData(1));
		}
		break;
	case Gr_StartStatement__start_Name_spLPar_Arguments_spRPar_spSemiCol:
		break;
	default:;
	}
}

void SemanticNodeStartStatement::analyzeStartAssignment(SyntaxTreeNode *syntaxNode){
	LexicUnit lu = CompilerData->Units->GetLexicUnit(syntaxNode->Nodes->GetData(0)->LexUnitID);
	startAssignmentNames.push_back(CompilerData->Units->GetLexicUnitString(&lu));
	startAssignmentExpressions.push_back(OurSemanticAnalyzer::analyzeNodeExpression(syntaxNode->Nodes->GetData(2), this));
}
SemanticNodeStartStatement::~SemanticNodeStartStatement(){

}
std::string SemanticNodeStartStatement::toDebugString(int tab){
	std::ostringstream res;
	for (int i = 0; i < tab; i++) res << DEBUG_STRING_RAZMAK;
	res << "start " << name;
	for (std::vector<SemanticNodeExpression *>::iterator i = arguments.begin(); i != arguments.end(); ++i)
		res << (*i)->toDebugString(tab + 1);
	for (unsigned int i = 0; i < startAssignmentNames.size(); i++){
		res << (startAssignmentNames[i]) << " ";
		res << (startAssignmentExpressions[i])->toDebugString(tab + 1);
	}
	return res.str();
}

/*
stop_statement>	~	stop <name> ;

<name>	 ~ 	NAME <name_add>
<name_add>	 ~	<name_period_add> <name_add>
<name_add>	 ~
<name_period_add> ~	. NAME

*/
SemanticNodeStopStatement::SemanticNodeStopStatement(const SyntaxTreeNode *syntaxNode, SemanticNode *parent):SemanticNode(parent){
	name = flattenNamePeriodAdd(*syntaxNode->Nodes->GetData(1));
}
SemanticNodeStopStatement::~SemanticNodeStopStatement(){

}
std::string SemanticNodeStopStatement::toDebugString(int tab){
	std::ostringstream res;
	for (int i = 0; i < tab; i++) res << DEBUG_STRING_RAZMAK;
	res << "stop " << name << endl;
	return res.str();
}
